package readini

import "fmt"

//Section all key and value in the ini file
type Section struct {
	KeyList []string
	Values  map[string]string
}

//newValue create a new Value
func (sec *Section) newValue(key string, value string) error {
	if _, ok := sec.Values[key]; ok {
		return fmt.Errorf("key(%v) already exists", key)
	}
	sec.KeyList = append(sec.KeyList, key)
	sec.Values[key] = value
	return nil
}

//GetValue return value according to key
func (sec *Section) GetValue(key string) (string, error) {
	if _, ok := sec.Values[key]; !ok {
		return "", fmt.Errorf("key(%v) does not exist", key)
	}
	return sec.Values[key], nil
}
